package cn.cloud.jianghai.orderservice.task;

import cn.cloud.jianghai.orderapi.entity.OrderDto;
import cn.cloud.jianghai.orderservice.query.OrderQuery;
import cn.cloud.jianghai.orderservice.service.OrderService;
import com.alibaba.fastjson.JSON;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Jiang.h
 * created 2022/5/31 16:58
 */
@Slf4j
@Component
public class OrderTask {

    @Autowired
    OrderService orderService;

    @XxlJob("orderList")
    public void orderList() {

        log.info("[订单列表] xxl-job 任务启动");

        List<OrderDto> orderList = orderService.findOrderList(new OrderQuery());

        log.info("返回数据体: {}", JSON.toJSONString(orderList));
    }
}
